package com.snow.fkisoftstone;

public class Utils {
    public static float getWorkTime(String startTime,String endTime){
        float startNum=getTime(startTime);
        float endNum=getTime(endTime);
        if (endNum>18.5){
            return endNum-startNum-2F;
        }else if (endNum>18){
            return 18F-startNum-1.5F;
        }else {
            return endNum-startNum-1.5F;
        }
    }

    private static float getTime(String timeStr){
        String[] times=timeStr.split(":");
        if (times.length==1){
            return Float.parseFloat(times[0]);
        }else if (times.length==2){
            return Float.parseFloat(times[0])+(Float.parseFloat(times[1])/60F);
        }
        return 0;
    }
}
